package binaryTree;

/**
 * @author kunkun
 * @className LeetCode_101
 * @Description ...
 * @date 2025/3/22 20:18
 */
public class LeetCode_101 {


    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    public boolean isSymmetric(TreeNode root) {
        return solution(root.left,root.right);
    }

    public boolean solution(TreeNode left,TreeNode right){
        if (left==null && right == null){
            return true;
        } else if (left!=null && right != null) {
            if (left.val == right.val){
                return solution(left.left,right.right) && solution(left.right,right.left);
            }
        }
        return false;

    }

}
